<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />

	<title>Class: Key</title>

	<link rel="stylesheet" href="./rdoc.css" type="text/css" media="screen" />

	<script src="./js/jquery.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/thickbox-compressed.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/quicksearch.js" type="text/javascript"
		charset="utf-8"></script>
	<script src="./js/darkfish.js" type="text/javascript"
		charset="utf-8"></script>

</head>
<body class="class">

	<div id="metadata">
		<div id="home-metadata">
			<div id="home-section" class="section">
        <h3 class="section-header">
          <a href="./index.html">Home</a>
          <a href="./index.html#classes">Classes</a>
          <a href="./index.html#methods">Methods</a>
        </h3>
			</div>
		</div>

		<div id="file-metadata">
			<div id="file-list-section" class="section">
				<h3 class="section-header">In Files</h3>
				<div class="section-body">
					<ul>
					
						<li><a href="./key_rb.html?TB_iframe=true&amp;height=550&amp;width=785"
							class="thickbox" title="key.rb">key.rb</a></li>
					
					</ul>
				</div>
			</div>

			
		</div>

		<div id="class-metadata">

			<!-- Parent Class -->
			
			<div id="parent-class-section" class="section">
				<h3 class="section-header">Parent</h3>
				
				<p class="link">Object</p>
				
			</div>
			

			<!-- Namespace Contents -->
			

			<!-- Method Quickref -->
			
			<div id="method-list-section" class="section">
				<h3 class="section-header">Methods</h3>
				<ul class="link-list">
					
					<li><a href="#method-c-new">::new</a></li>
					
					<li><a href="#method-i-%2B">#+</a></li>
					
					<li><a href="#method-i--">#-</a></li>
					
					<li><a href="#method-i-is_in_range">#is_in_range</a></li>
					
					<li><a href="#method-i-to_s">#to_s</a></li>
					
				</ul>
			</div>
			

			<!-- Included Modules -->
			
		</div>

		<div id="project-metadata">
			
			

			<div id="classindex-section" class="section project-section">
				<h3 class="section-header">Class Index
					<span class="search-toggle"><img src="./images/find.png"
						height="16" width="16" alt="[+]"
						title="show/hide quicksearch" /></span></h3>
				<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
				<fieldset>
					<legend>Quicksearch</legend>
					<input type="text" name="quicksearch" value=""
						class="quicksearch-field" />
				</fieldset>
				</form>

				<ul class="link-list">
				
					<li><a href="./Chorb.html">Chorb</a></li>
				
					<li><a href="./Chorb/Chord.html">Chorb::Chord</a></li>
				
					<li><a href="./AbstractVirtualNode.html">AbstractVirtualNode</a></li>
				
					<li><a href="./Key.html">Key</a></li>
				
					<li><a href="./ListenerVirtualNode.html">ListenerVirtualNode</a></li>
				
					<li><a href="./LocalVirtualNode.html">LocalVirtualNode</a></li>
				
					<li><a href="./RemoteVirtualNode.html">RemoteVirtualNode</a></li>
				
				</ul>
				<div id="no-class-search-results" style="display: none;">No matching classes.</div>
			</div>

			
		</div>
	</div>

	<div id="documentation">
		<h1 class="class">Key</h1>

		<div id="description">
			<p>
Representa uma chave usada no Chord ring. As chaves sao usadas tanto para
identificar os no&#8217;s quanto para identificar os elementos presentes
no Chord. O hash usado para gerar a chave aqui e&#8217; o SHA2.
</p>

		</div>

		<!-- Constants -->
		
		<div id="constants-list" class="section">
			<h3 class="section-header">Constants</h3>
			<dl>
			
				<dt><a name="MAX_VALUE">MAX_VALUE</a></dt>
				
				<dd class="description"></dd>
				
			
			</dl>
		</div>
		

		<!-- Attributes -->
		
		<div id="attribute-method-details" class="method-section section">
			<h3 class="section-header">Attributes</h3>

			
			<div id="key-attribute-method" class="method-detail">
				<a name="key"></a>
				
				<a name="key="></a>
				
				<div class="method-heading attribute-method-heading">
					<span class="method-name">key</span><span
						class="attribute-access-type">[RW]</span>
				</div>

				<div class="method-description">
				
				
				
				</div>
			</div>
			
		</div>
		

		<!-- Methods -->
		
		<div id="public-class-method-details" class="method-section section">
			<h3 class="section-header">Public Class Methods</h3>

		
			<div id="new-method" class="method-detail ">
				<a name="method-c-new"></a>

				<div class="method-heading">
				
					<span class="method-name">new</span><span
						class="method-args">(value)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Construtor. Calcula o hash para essa chave de acordo com o valor passado.
</p>
					

					
					<div class="method-source-code"
						id="new-source">
<pre>
    <span class="ruby-comment cmt"># File key.rb, line 14</span>
14:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">value</span>)
15:     <span class="ruby-ivar">@key</span> = <span class="ruby-constant">Digest</span><span class="ruby-operator">::</span><span class="ruby-constant">SHA2</span>.<span class="ruby-identifier">hexdigest</span>(<span class="ruby-identifier">value</span>).<span class="ruby-identifier">hex</span>
16:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	
		<div id="public-instance-method-details" class="method-section section">
			<h3 class="section-header">Public Instance Methods</h3>

		
			<div id="--method" class="method-detail ">
				<a name="method-i-%2B"></a>

				<div class="method-heading">
				
					<span class="method-name">+</span><span
						class="method-args">(number)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Soma duas chaves.
</p>
					

					
					<div class="method-source-code"
						id="--source">
<pre>
    <span class="ruby-comment cmt"># File key.rb, line 44</span>
44:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">+</span>(<span class="ruby-identifier">number</span>)
45:     <span class="ruby-identifier">number</span> = <span class="ruby-identifier">number</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">number</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Key</span>)
46: 
47:     <span class="ruby-identifier">key</span> = <span class="ruby-constant">Key</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'a'</span>)
48:     <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> = <span class="ruby-ivar">@key</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">number</span>
49:     <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">-=</span> <span class="ruby-constant">MAX_VALUE</span>.<span class="ruby-identifier">hex</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">MAX_VALUE</span>.<span class="ruby-identifier">hex</span>
50:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">key</span>
51:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="--method" class="method-detail ">
				<a name="method-i--"></a>

				<div class="method-heading">
				
					<span class="method-name">-</span><span
						class="method-args">(number)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Subtrai duas chaves.
</p>
					

					
					<div class="method-source-code"
						id="--source">
<pre>
    <span class="ruby-comment cmt"># File key.rb, line 54</span>
54:   <span class="ruby-keyword kw">def</span> <span class="ruby-operator">-</span>(<span class="ruby-identifier">number</span>)
55:     <span class="ruby-identifier">number</span> = <span class="ruby-identifier">number</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">number</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Key</span>)
56: 
57:     <span class="ruby-identifier">key</span> = <span class="ruby-constant">Key</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'a'</span>)
58:     <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> = <span class="ruby-ivar">@key</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">number</span>
59:     <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> = <span class="ruby-constant">MAX_VALUE</span>.<span class="ruby-identifier">hex</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">key</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
60:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">key</span>
61:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="is-in-range-method" class="method-detail ">
				<a name="method-i-is_in_range"></a>

				<div class="method-heading">
				
					<span class="method-name">is_in_range</span><span
						class="method-args">(start_key, end_key, include_start_key = true, include_end_key = true)</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					<p>
Determina se esta chave esta no intervalor passado. Esse intervalo comeca
em start_key e termina em end_key. Os parametros include_start_key e
include_end_key determinam se as chaves no entremo do intervalos devem ser
incluidas ou nao.
</p>
					

					
					<div class="method-source-code"
						id="is-in-range-source">
<pre>
    <span class="ruby-comment cmt"># File key.rb, line 22</span>
22:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">is_in_range</span>(<span class="ruby-identifier">start_key</span>, <span class="ruby-identifier">end_key</span>, <span class="ruby-identifier">include_start_key</span> = <span class="ruby-keyword kw">true</span>, <span class="ruby-identifier">include_end_key</span> = <span class="ruby-keyword kw">true</span>)
23:     <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">include_start_key</span>
24:       <span class="ruby-identifier">start_key</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
25:     <span class="ruby-keyword kw">end</span>
26:     
27:     <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">include_end_key</span>
28:       <span class="ruby-identifier">end_key</span> <span class="ruby-operator">-=</span> <span class="ruby-value">1</span>
29:     <span class="ruby-keyword kw">end</span>
30:        
31:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">start_key</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">end_key</span>.<span class="ruby-identifier">key</span>
32:       <span class="ruby-keyword kw">return</span> ((<span class="ruby-ivar">@key</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">end_key</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@key</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">start_key</span>.<span class="ruby-identifier">key</span>) <span class="ruby-keyword kw">or</span>
33:              (<span class="ruby-ivar">@key</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">start_key</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@key</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">end_key</span>.<span class="ruby-identifier">key</span>))
34:     <span class="ruby-keyword kw">else</span>
35:       <span class="ruby-keyword kw">return</span> (<span class="ruby-ivar">@key</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">start_key</span>.<span class="ruby-identifier">key</span> <span class="ruby-keyword kw">and</span> <span class="ruby-ivar">@key</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-identifier">end_key</span>.<span class="ruby-identifier">key</span>)
36:     <span class="ruby-keyword kw">end</span>
37:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
			<div id="to-s-method" class="method-detail ">
				<a name="method-i-to_s"></a>

				<div class="method-heading">
				
					<span class="method-name">to_s</span><span
						class="method-args">()</span>
					<span class="method-click-advice">click to toggle source</span>
				
				</div>

				<div class="method-description">
					
					
					

					
					<div class="method-source-code"
						id="to-s-source">
<pre>
    <span class="ruby-comment cmt"># File key.rb, line 39</span>
39:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
40:     <span class="ruby-ivar">@key</span>.<span class="ruby-identifier">to_s</span>
41:   <span class="ruby-keyword kw">end</span></pre>
					</div>
					
				</div>

				

				
			</div>

		
		</div>
	

	</div>


	<div id="rdoc-debugging-section-dump" class="debugging-section">
	
		<p>Disabled; run with --debug to generate this.</p>
	
	</div>

	<div id="validator-badges">
		<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
		<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
			Rdoc Generator</a> 1.1.6</small>.</p>
	</div>

</body>
</html>

